package com.itheima.topic4;

public class LambdaTest4 {
    public static void main(String[] args) {
        int rs = new CalculatorDemo().useCalculator(1, 2, new Calculator() {
            @Override
            public int calc(int a, int b) {
                return a+b;
            }
        });
        System.out.println("1+2="+rs);
        System.out.println("----------------------------------------------------");

        int rs2 = new CalculatorDemo().useCalculator(1, 2, ( a, b) -> a*b
        );
        System.out.println("1*2="+rs2);
    }
}

interface Calculator{
    int calc(int a, int b);
}

class CalculatorDemo{
    int useCalculator(int a,int b,Calculator calculator){
        return calculator.calc(a,b);
    }
}